from flask import Flask, request, render_template, \
    redirect, url_for

app = Flask(__name__)


@app.route('/')
def index():
    return render_template('index.html')


@app.route('/register', methods=['GET', 'POST'])
def register():
    if request.method == "GET":
        return render_template('register.html')
    else:
        username = request.form.get('username')
        password = request.form.get('password')
        print('用户名:', username)
        print('密码:', password)
        # return render_template('index.html')
        # return redirect('/')
        return redirect(url_for("index"))


if __name__ == '__main__':
    app.run()
